#ifndef RESULT_H
#define RESULT_H

#include <QWidget>
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <QLabel>
#include <QPalette>
#include <QBrush>
#include <QColor>
#include <QSize>

#include "defines.h"


class Result : public QTreeWidget {
 Q_OBJECT
public:
  Result(QWidget *parent = 0);

  double area() { return insArea;  };
  void setArea(double newArea) { insArea = newArea; updateVar(VAR_AREA); };
  void setAddStrArea(const QString & newVal) { addStrArea = newVal; updateVar(VAR_AREA); };

  double perimeter() { return insPerimeter;  };
  void setPerimeter(double newPerimeter) { insPerimeter = newPerimeter; updateVar(VAR_PERIMETER); };
  void setAddStrPerimeter(const QString & newVal) { addStrPerimeter = newVal; updateVar(VAR_PERIMETER); };

  double radius() { return insRadius;  };
  void setRadius(double newRadius) { insRadius = newRadius; updateVar(VAR_RADIUS); };
  void setAddStrRadius(const QString & newVal) { addStrRadius = newVal; updateVar(VAR_RADIUS); };

  double shezy() { return insShezy;  };
  void setShezy(double newShezy) { insShezy = newShezy; updateVar(VAR_SHEZY); };
  void setAddStrShezy(const QString & newVal) { addStrShezy = newVal; updateVar(VAR_SHEZY); };

  double AQ() { return insAQ; };
  void setAQ(double newAQ) { insAQ = newAQ; updateVar(VAR_AQ); };
  void setAddStrAQ(const QString & newVal) { addStrAQ = newVal; updateVar(VAR_AQ); };

  double Hrain() { return insHrain; };
  void setHrain(double newHrain) { insHrain = newHrain; updateVar(VAR_HRAIN); };
  void setAddStrHrain(const QString & newVal) { addStrHrain = newVal; updateVar(VAR_HRAIN); };

  double qRainCon() { return insqRainCon; };
  void setqRainCon(double newqRainCon) { insqRainCon = newqRainCon; updateVar(VAR_QRAINCON); };
  void setAddStrRainCon(const QString & newVal) { addStrRainCon = newVal; updateVar(VAR_QRAINCON); };

  double Qr() { return insQr; };
  void setQr(double newQr) { insQr = newQr; updateVar(VAR_QR); };
  void setAddStrQr(const QString & newVal) { addStrQr = newVal; updateVar(VAR_QR); };

  double Qcr() { return insQcr; };
  void setQcr(double newQcr) { insQcr = newQcr; updateVar(VAR_QCR); };
  void setAddStrQcr(const QString & newVal) { addStrQcr = newVal; updateVar(VAR_QCR); };

  double Qrec() { return insQrec; };
  void setQrec(double newQrec) { insQrec = newQrec; updateVar(VAR_QREC); };
  void setAddStrQrec(const QString & newVal) { addStrQrec = newVal; updateVar(VAR_QREC); };

  double Hrec() { return insHrec; };
  void setHrec(double newHrec) { insHrec = newHrec; updateVar(VAR_HREC); };
  void setAddStrHrec(const QString & newVal) { addStrHrec = newVal; updateVar(VAR_HREC); };

  double Hcr() { return insHcr; };
  void setHcr(double newHcr) { insHcr = newHcr; updateVar(VAR_HCR); };
  void setAddStrHcr(const QString & newVal) { addStrHcr = newVal; updateVar(VAR_HCR); };

  double Icr() { return insIcr; };
  void setIcr(double newIcr) { insIcr = newIcr; updateVar(VAR_ICR); };
  void setAddStrIcr(const QString & newVal) { addStrIcr = newVal; updateVar(VAR_ICR); };

  double Vs() { return insVs; };
  void setVs(double newVs) { insVs = newVs; updateVar(VAR_VS); };
  void setAddStrVs(const QString & newVal) { addStrVs = newVal; updateVar(VAR_VS); };

  double Vr() { return insVr; };
  void setVr(double newVr) { insVr = newVr; updateVar(VAR_VR); };
  void setAddStrVr(const QString & newVal) { addStrVr = newVal; updateVar(VAR_VR); };

  double Vd() { return insVd; };
  void setVd(double newVd) { insVd = newVd; updateVar(VAR_VD); };
  void setAddStrVd(const QString & newVal) { addStrVd = newVal; updateVar(VAR_VD); };

  double getVal(int varName);

protected:
  //Обновить вывод значения переменной
  void updateVar(int varName);
  void setLab(int varName, const QString & newStr);

//Вывод
  QLabel * nameResRainWater;
   QLabel * nameVs;
   QLabel * nameVr;
   QLabel * nameVd;
  QLabel * nameResTray;
   QLabel * nameIcr;
   QLabel * nameArea;
   QLabel * namePerimeter;
   QLabel * nameRadius;
   QLabel * nameShezy;
   QLabel * nameAQ;
  QLabel * nameQs;
   QLabel * nameqRainCon;
   QLabel * nameQr;
   QLabel * nameQcr;
   QLabel * nameQrec;
  QLabel * nameHs;
   QLabel * nameHrain;
   QLabel * nameHcr;
   QLabel * nameHrec;

  QTreeWidgetItem * item;

//Вывод
   QTreeWidgetItem * itemResRainWater;
    QTreeWidgetItem * itemVs;
    QTreeWidgetItem * itemVr;
    QTreeWidgetItem * itemVd;
   QTreeWidgetItem * itemResTray;
    QTreeWidgetItem * itemIcr;
    QTreeWidgetItem * itemArea;
    QTreeWidgetItem * itemPerimeter;
    QTreeWidgetItem * itemRadius;
    QTreeWidgetItem * itemShezy;
    QTreeWidgetItem * itemAQ;
   QTreeWidgetItem * itemQs;
    QTreeWidgetItem * itemqRainCon;
    QTreeWidgetItem * itemQr;
    QTreeWidgetItem * itemQcr;
    QTreeWidgetItem * itemQrec;
   QTreeWidgetItem * itemHs;
    QTreeWidgetItem * itemHrain;
    QTreeWidgetItem * itemHcr;
    QTreeWidgetItem * itemHrec;

  //Палитра
  QPalette palette;
  
  QLabel * labArea;
  double insArea;
  QString addStrArea;

  QLabel * labPerimeter;
  double insPerimeter;
  QString addStrPerimeter;

  QLabel * labRadius;
  double insRadius;
  QString addStrRadius;

  QLabel * labShezy;
  double insShezy;
  QString addStrShezy;

  QLabel * labAQ;
  double insAQ;
  QString addStrAQ;

  QLabel * labqRainCon;
  double insqRainCon;
  QString addStrRainCon;

  QLabel * labHrain;
  double insHrain;
  QString addStrHrain;

  QLabel * labHrec;
  double insHrec;
  QString addStrHrec;

  QLabel * labQrain;
  double insQrain;
  QString addStrQrain;

  QLabel * labQr;
  double insQr;
  QString addStrQr;

  QLabel * labQcr;
  double insQcr;
  QString addStrQcr;

  QLabel * labQrec;
  double insQrec;
  QString addStrQrec;

  QLabel * labHcr;
  double insHcr;
  QString addStrHcr;

  QLabel * labIcr;
  double insIcr;
  QString addStrIcr;

  QLabel * labVs;
  double insVs;
  QString addStrVs;

  QLabel * labVr;
  double insVr;
  QString addStrVr;

  QLabel * labVd;
  double insVd;
  QString addStrVd;

//Конвертирование кодировки
  QTextCodec * russianCodec;

  //Убирает незначащие цифры после запятой
  double toPrec(double num) { double d = fmod(num, 0.01); return  num - d + double(rint(d * 1000))/1000; };

}; //class Result : public QTreeWidget

#endif
